package lc_剑指_Offer_66_构建乘积数组;

public class Solution {
	public int[] constructArr(int[] a) {
		int n = a.length;
		if(n == 0)
            return a;
		int b[] = new int[n], l[] = new int[n];
		l[0] = 1;
		for (int i = 1; i < n; i++) {
			l[i] = l[i - 1] * a[i - 1];
		}
		for (int i = n - 1, r = 1; i >= 0; r *= a[i], i--) {
			b[i] = l[i] * r;
		}
		return b;
	}
}